#include "t_httpbackend.h"
#include "t_httpreply.h"

QObject *T_MyBackendFactory::create(QNetworkAccessManager * manager,
                        QNetworkAccessManager::Operation op,
                        const QNetworkRequest & request,
                        QIODevice * outgoingData) const
{
	//qDebug() << "T_MyBackendFactory::create()" << request.url();
    QString v_scheme = request.url().scheme().toLower();
    if(v_scheme != "http" && v_scheme != "https")
    {
        return NULL;
    }
    return new T_HttpAccessBackend(manager);
}

NetworkHttpReply *T_HttpAccessBackend::createHttpReply()
{
    qDebug()<< "[T_HttpAccessBackend::createHttpReply()]"
            << QNetworkAccessBackend::url()
            ;
    if(
            this->isGetOperation()
            &&
            QNetworkAccessBackend::url().toString().contains(".youtube.com/videoplayback?")
            )
    {
        return new T_HttpReply_3(this);
    }
    return new T_HttpReply_1(this);
}
